Skip to content

Introduce createBufferWithData function for easy buffer creation.#1208

Merged
manon-traverse merged 5 commits into
llvm:mainfrom
Traverse-Research:create-buffer-with-data
May 22, 2026
Merged

Introduce createBufferWithData function for easy buffer creation.#1208
manon-traverse merged 5 commits into
llvm:mainfrom
Traverse-Research:create-buffer-with-data

Conversation

@manon-traverse

Copy link
Copy Markdown
Contributor

As a step towards making resource and descriptor creation the same across graphics APIs we need a function to handle creating buffers and uploading data. This includes optionally creating an upload buffer.

Right now, it's only used to create the vertex buffer and avoids the use of an upload buffer by placing the vertices in host visible memory.

In a future PR, all generic buffers should be created via this path, and the same for textures with similar functions. However, this is quite a bit of refactoring. Ideally, we do this in smaller steps so PRs are easier to review. On top of that, this work is fairly low priority.

Ideally at some point we do introduce lifetime tracking so that createBufferWithData becomes even easier to use since the caller won't have to care about keeping the upload buffer alive.

@manon-traverse manon-traverse force-pushed the create-buffer-with-data branch from 941605f to 84cc421 Compare May 19, 2026 15:43

@MarijnS95 MarijnS95 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that is a nice approach.

(Albeit a bit hacky, this flow makes it easy to experiment with upload-less UMA by simply overriding all buffers to be CpuToGpu in createBufferWithData() 🙂)

@manon-traverse

Copy link
Copy Markdown
Contributor Author

Yes that is a nice approach.

(Albeit a bit hacky, this flow makes it easy to experiment with upload-less UMA by simply overriding all buffers to be CpuToGpu in createBufferWithData() 🙂)

At some point we could also check if the device is UMA and just map the GpuOnly buffer directly.

@bogner bogner left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but my comment here kind of applies generally across a lot of preexisting code.

Comment thread include/API/Buffer.h Outdated
@manon-traverse manon-traverse merged commit 6328072 into llvm:main May 22, 2026
21 of 22 checks passed
@MarijnS95 MarijnS95 deleted the create-buffer-with-data branch May 22, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants